function canConstruct(ransomNote, magazine) {
    
    const charCount = {};
    for (let char of magazine){
        if(charCount[char]){
            charCount[char]++
        }else{
            charCount[char] = 1
        }
    }

    for (let char of ransomNote){
        if(charCount[char] > 0){
            charCount[char]--
        }else{
            return false
        }
    }

    return true; 
}

// 测试示例
console.log(canConstruct("a", "b")); // false
console.log(canConstruct("aa", "ab")); // false
console.log(canConstruct("aa", "aab")); // true